app.controller('DecorateReview', function($element, $scope, $state, rest, uploadConf, $http, $location, ngDialog, user, $window, tipService) {
    var data = angular.copy($scope.ngDialogData, {});
    console.log(data.decorateId);

    $scope.params = {};
    // 支付方式
    var payTypeList = ['一月一付','三月一付','六月一付','一年一付'];

    $scope.column2 = 0;      //分栏
    $scope.maxImgNum = 1;    //最大图片数量
    $scope.imgNew= [
        {
            text:'合同图片集合',
            name: 'contractPics',
            value: [],
            picType: 11
        },
        {
            text:'路牌照片',
            name: 'roadPics',
            value: [],
            picType: 12
        },
        {
            text:'门牌照片',
            name: 'doorplatePics',
            value: []
        },
        {
            text:'半开门照片',
            name: 'doubleDoorPics',
            value: [],
            picType: 13
        },
        {
            text:'房产证照片',
            name: 'houseCardPics',
            value: [],
            picType: 14
        },
        {
            text:'小区门口照片',
            name: 'doorPhotoPics',
            value: [],
            picType: 15
        }
    ];   
    uploadConf.column2 = $scope.column2;
    uploadConf.maxImgNum =  $scope.maxImgNum;
    uploadConf.imgNew = $scope.imgNew; 


    rest.post({
        methodId: '4015',
        data: {
            decorateId: data.decorateId
        },
        success: function(res) {
            if (res.code == 0) {
              var data = res.res.data;
              console.log(data)
              // $scope.contractPics = data.contractPics;
              // $scope.doorplatePics = data.doorplatePics;
              // $scope.doubleDoorPics = data.doubleDoorPics;
              // $scope.houseCardPics = data.houseCardPics;
              // $scope.roadPics = data.roadPics;
              // $scope.doorPhotoPics = data.doorPhotoPics;
              $scope.expectAmount = data.expectAmount;
              $scope.contractStartDate = data.contractStartDate.substring(0,10);
              $scope.contractEndDate = data.contractEndDate.substring(0,10);
              uploadConf.imgNew[0].value = data.contractPics;
              uploadConf.imgNew[1].value = data.roadPics;
              uploadConf.imgNew[2].value = data.doorplatePics;
              uploadConf.imgNew[3].value = data.doubleDoorPics;
              uploadConf.imgNew[4].value = data.houseCardPics;
              uploadConf.imgNew[5].value = data.doorPhotoPics;

              if( data.checkStatus == '2' ) {
                $scope.showStatus = true;
                $scope.reason = data.remark;
              }else if( data.checkStatus == '1' ) {
                $scope.showStatus1 = true;
                $scope.reason1 = data.remark;
              }
            }
            $scope.$digest();
        },
        error: function() {}
    })

});

app.controller('ContractTimeCtrl',function($scope){
  $scope.today = function() {
      // $scope.contractStartDate = moment().format('YYYY/MM/DD');
      // $scope.contractEndDate = moment().add(2,'years').subtract(1, 'days').format('YYYY/MM/DD');
    };

    $scope.closeAll = function() {
      $scope.openContractBeginDated =
      $scope.openContractEndDated = false;
    }

    $scope.openContractBeginDate = function($event) {
      $event.preventDefault();$event.stopPropagation();$scope.closeAll();
      $scope.openContractBeginDated = true;
    };
    $scope.openContractEndDate = function($event) {
      $event.preventDefault();$event.stopPropagation();$scope.closeAll();
      $scope.openContractEndDated = true;
    };

    $scope.dateOptions = {
      format: 'yyyy/MM/dd',
      startingDay: 1,
      class: 'datepicker'
    };

    $scope.format = 'yyyy/MM/dd';

    $scope.today();

    $scope.$watch('contractStartDate',function(newValue,oldValue){
      if("[object Date]" === Object.prototype.toString.call(newValue)) {
         $scope.$emit('contractDate.start',moment(newValue).format('YYYY/MM/DD'))
      }
    });
    $scope.$watch('contractEndDate',function(newValue,oldValue){
      if("[object Date]" === Object.prototype.toString.call(newValue)) {
         $scope.$emit('contractDate.end',moment(newValue).format('YYYY/MM/DD'))
      }
    });
});
